<?php
class Withdraw_model extends CI_Model {

    public function __construct()
    {
        parent::__construct();
        $this->load->database();
    }

    public function get_all_withdraw($per_page,$page_no)
    {
        $this->db->join('users','openid=wd_openid');
        $this->db->limit($per_page,$per_page*($page_no-1));
        $this->db->order_by('wd_time','desc');
        return $this->db->get('withdraw_deposit')->result_array();
    }

    public function get_withdraw_num(){
        $this->db->select('count(wd_no) sum');
        return $this->db->get('withdraw_deposit')->row_array()['sum'];
    }

    public function get_all_record($per_page,$page_no)
    {
        $this->db->select('nickName,avatarUrl,records.*');
        $this->db->join('users','users.openid=records.openid');
        $this->db->limit($per_page,$per_page*($page_no-1));
        $this->db->order_by('time_end','desc');
        return $this->db->get('records')->result_array();
    }

    public function get_record_num(){
        $this->db->select('count(id) sum');
        return $this->db->get('records')->row_array()['sum'];
    }
}
?>
